<?php
/**
 * 角色管理模板
 * User: lvshuyun
 * Date: 2015/6/8
 * Time: 17:28
 */

use yii\helpers\Html;
use kartik\grid\GridView;

$this->title = '管理员组管理';


echo GridView::widget([
    'dataProvider' => $dataProvider,
    'panel' => [
        'type' => GridView::TYPE_DEFAULT,
        'heading' => '管理员列表',
    ],
    'toolbar' => [
        ['content' => Html::a('<i class="glyphicon glyphicon-plus"></i> 新增角色', ['admin-role/add'], ['class' => 'btn btn-primary'])],
        '{toggleData}'
    ],
    'columns' => [
        ['class' => 'yii\grid\SerialColumn'],
        'roleName',
        [
            'label' => '所属代理商',
            'attribute' => 'agentID',
            'value' => function($model){
                if(empty($model->agentID)){
                    return '系统';
                }else{
                    if(!empty($this->agent)){
                        return $model->agent->agentSN;
                    }else{
                        return '查不到';
                    }

                }
            }
        ],
        [
            'class' => 'common\widgets\ActionColumn',
            'template' => '{edit} {delete}',
        ],

    ],
]);